package com.itheima.common.domain;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.Data;

import java.util.List;

@Data
public class PageInfo {
    /**
     * 当前记录起始索引
     */
    private Long pageNum;

    /**
     * 每页显示记录数
     */
    private Long pageSize;

    private Long total;

    private Long totalPage;

    private List<?> list;

    public static PageInfo toPageList(Page page) {
        PageInfo pageInfo = new PageInfo();
        pageInfo.setList(page.getRecords());
        pageInfo.setPageNum(page.getCurrent());
        pageInfo.setPageSize(page.getSize());
        pageInfo.setTotal(page.getTotal());
        pageInfo.setTotalPage(page.getPages());
        return pageInfo;
    }
}
